package renguanyu.app.auth4fx.view;

import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import renguanyu.app.auth4fx.view.permission.PermissionListView;
import renguanyu.app.auth4fx.view.role.RoleListView;
import renguanyu.app.auth4fx.view.user.UserListView;

public class MainView extends BorderPane {

    public MainView() {
        MenuBar menuBar = new MenuBar();
        Menu authMenu = createAuthMenu();
        menuBar.getMenus().addAll(authMenu);
        super.setTop(menuBar);
    }

    private Menu createAuthMenu() {
        Menu systemMenu = new Menu("系统管理");
        MenuItem userMenu = new MenuItem("用户管理");
        MenuItem roleMenu = new MenuItem("角色管理");
        MenuItem permissionMenu = new MenuItem("权限管理");
        userMenu.setOnAction(e -> super.setCenter(new UserListView()));
        roleMenu.setOnAction(e -> super.setCenter(new RoleListView()));
        permissionMenu.setOnAction(e -> super.setCenter(new PermissionListView()));
        systemMenu.getItems().setAll(
            userMenu,
            roleMenu,
            permissionMenu
        );
        return systemMenu;
    }
}
